package com.framerock.server;

import com.framerock.baselib.CLog;
import com.framerock.baselib.Rock;
import com.framerock.db.DB;
import com.framerock.db.DBConn;
import com.framework.Table.TableAll;

import java.util.Map;

public class MainServer {

    public static void start(String action, Map<String, String> configMap)
    {
        String actiona[] = new String[]{"createdb", "updatedb"};
        if(Rock.inArray(actiona, action)){
            CLog.print("--"+action+"ing--");
            DBConn ndb = DB.getDbobj();
            TableAll.queryTable(ndb, action, Rock.getMapString(configMap, "num"), Rock.getMapString(configMap, "group")); //更新创建数据库
            ndb.close();
            CLog.print("--"+action+"success--");
        }else if(action.equals("taskrun")){
            CLog.print("--taskruning--");
            CLog.print("--taskrunsuccess--");
        }else if(action.equals("start")) {
            HttpServer.start(); //主Http服务运行
            TaskServer.start(); //主Task服务运行
        }else{
            InputServer.start();
        }
    }
}
